// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   ReadWriteFile.java

package include.nseer_cookie;

import java.io.*;
import java.net.URL;

public class ReadWriteFile
{

	public ReadWriteFile()
	{
	}

	public void execute(String readFile, String special)
	{
		try
		{
			String strClassName = getClass().getName();
			String strPackageName = "";
			if (getClass().getPackage() != null)
				strPackageName = getClass().getPackage().getName();
			String strClassFileName = "";
			if (!"".equals(strPackageName))
				strClassFileName = strClassName.substring(strPackageName.length() + 1, strClassName.length());
			else
				strClassFileName = strClassName;
			URL url = getClass().getResource((new StringBuilder(String.valueOf(strClassFileName))).append(".class").toString());
			String strURL = url.toString();
			strURL = strURL.substring(strURL.indexOf('/') + 1, strURL.lastIndexOf('/'));
			String strURL2 = strURL.substring(0, strURL.lastIndexOf("WEB-INF"));
			String strURL1 = (new StringBuilder(String.valueOf(strURL2))).append("WEB-INF/").toString();
			readFile = (new StringBuilder(String.valueOf(strURL1))).append(readFile).toString();
			String writeFile = (new StringBuilder(String.valueOf(strURL1))).append(special).append(".sql").toString();
			File write_aim = new File(writeFile);
			write_aim.createNewFile();
			String line = "";
			BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(writeFile), "UTF-8"));
			BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(readFile), "UTF-8"));
			while ((line = bufferedReader.readLine()) != null) 
			{
				bufferedWriter.write(line.replace("ondemand1", special));
				bufferedWriter.newLine();
			}
			bufferedWriter.flush();
			bufferedWriter.close();
			bufferedReader.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
